﻿using System.Collections.Generic;
using System.IO;

public static class AllLevels
{
    public static List<string> Levels;

    static AllLevels()
    {
        Levels = new List<string> { "Waiting", "Menu", "Map", "Tutorial", "WallJump", "GrassTest" };

        DirectoryInfo directory = new DirectoryInfo("Custom Levels");
        if (directory.Exists)
            foreach (FileInfo fileInfo in directory.GetFiles())
            {
                string newLevel = fileInfo.Name;
                if (newLevel.Substring(newLevel.Length - 4) == ".map")
                {
                    newLevel = newLevel.Remove(newLevel.Length - 4, 4);
                    Levels.Add(newLevel);
                }
            }
    }

    public static string GetLevelNameById(int id)
    {
        return Levels[id];
    }

    public static int GetLevelIdByName(string name)
    {
        int id = -1;
        for (int i = 0; i < Levels.Count; i++)
        {
            if (Levels[i] == name)
            {
                id = i;
                break;
            }
        }
        return id;
    }
}